home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
OTHER_LA
/
0289.ZIP
/
LIST.LST
< prev
next >
Wrap
File List
|
1986-11-23
|
6KB
|
123 lines
*
-PLUSOPS 1
*
* LIST
* This is a Datapoint DOS-style LIST program. It lists input files,
* either text or print files. It can number output (default), or not.
* It generates page headings with page numbers. Page length can be
* specified on the command line. Tab characters can be expanded to
* any desired number of columns. Output may either write a new or
* append to an existing file. Default is to output to the printer PRN:.
* Parameter descriptions for LIST are described in the accompanying
* file UTILSDOC.TXT.
* The program was written in July 1986 by Gordon E. Peterson II,
* P.O. Box 40476, San Antonio, Texas 78229 (U.S.A.). The program
* may be freely distributed. If you find it to be useful, a five or
* ten dollar contribution sent to the author at the above address would
* be appreciated. This will also make it possible to notify you of
* periodic improvements to this program; and to let you know of
* some of the many other useful utilities also available.
*
1 &FULLSCAN = &TRIM = 1
*
2 SCREEN = "LIST 1.00 File Listing Utility" CHAR(13) CHAR(10)
2 + " Copyright 1986, Gordon E. Peterson II" CHAR(13) CHAR(10)
*
* Next define some standard character sets and patterns we will use to
* scan off the file names and such on the command line, and to use for
* tab character expansion.
*
3 ALPHNUM = (ALPHA = &UCASE &LCASE) (DECDIGS = "0123456789")
4 PATH_CHRS = (PATHCHRS2 = "!#$%&'()*^@_`~{}-" DECDIGS) "."
5 OB = (WHITE = SPAN(' ' CHAR(9))) | NULL
6 NAMEPAT = SPAN(ALPHA PATHCHRS2)
7 INTEGER = SPAN(DECDIGS)
8 FILENMP = NAMEPAT $ TEMPX *LE(SIZE(TEMPX),8)
9 FILEXTP2 = (NAMEPAT | NULL) $ TEMPX *LE(SIZE(TEMPX),3)
10 PATHP = (((ANY(ALPHA) ':') | NULL)
10 + ARBNO((SPAN(ALPHA PATH_CHRS) | NULL) "\") SPAN(ALPHA PATH_CHRS)) |
10 + (SPAN(ALPHNUM) ":")
11 OPTSEP = ANY(":=") | NULL
12 INFPAT = ";" OB PATHP $ FIN ((((OB "," OB) | WHITE)
12 + (PATHP . FOUT)) | (NULL . FOUT))
13 RTCPAT = CHAR(9) @TCPOS
*
* Program Main Code begins here.
* First, process the options.
*
14 UPARM = REPLACE((&PARM ? ";" REM),&LCASE,&UCASE) " " :F(NOPT)
*
* Get input file name & output file spec if any.
*
15 UPARM INFPAT ANY("/ ")
16 SCREEN = IDENT(FIN) "No valid input file was specified." :S(END)
17 SCREEN = ~INPUT("INREC",1,150,FIN) "I cannot find input file "
17 + FIN :S(END)
*
* Check if we are supposed to write an output file. If so, and if there
* was no output file spec given, we will default the file name to the same
* as the name of the input file.
*
18 FOUT = ?(UPARM ? "/P") IDENT(FOUT) :F(NODEFONM)
19 FOUT = ((FIN ? "." FILEXTP2 RPOS(0) = ), FIN)
*
* If an output file was specified but no extension, default the extension
* to .LST.
*
20 NODEFONM FOUT FILENMP RPOS(0) = FOUT ".LST"
21 &FULLSCAN = 0
*
* The following six statements could be trivially reduced to a single
* statement but are being left separate for clarity.
*
* Check if we are to suppress line numbers. (SLNO = NULL if not)
*
22 UPARM "/X" . SLNO
*
* Check if number of blanks per tabulation has been specified. Default to
* eight if not.
*
23 NBT = 8
24 UPARM "/T" OPTSEP INTEGER . NBT
*
* Check if number of lines per page has been specified. Default to 55.
*
25 NLP = 55
26 UPARM "/N" OPTSEP INTEGER . NLP
*
* Check if we are listing an already-formatted file. (IFAF = NULL if not)
*
27 UPARM "/F" . IFAF
*
* Check if appending to disk output file. Also, if no output file has been
* specified, here is where we will default the output to the printer. Open
* the output file and give an error message if we can't. Exit in that case.
*
28 SCREEN = ~OUTPUT("OUTREC",2,"W,131" ( ?(UPARM ? "/Q") ",E",NULL),
28 + (FOUT = (DIFFER(FOUT) FOUT, "PRN:")))
28 + "Sorry, I cannot open " FOUT " for output." :S(END)
*
* Read an input line
*
29 LOOP LINE = INREC :F(END)
30 OUTREC = DIFFER(IFAF) LINE :S(LOOP)
*
* Replace any tab characters with blanks as necessary.
*
31 TXPLOOP LINE RTCPAT = DUPL(" ",NBT - REMDR(TCPOS - 1,NBT))
31 + :S(TXPLOOP)
*
* Output the line as requested.
*
32 IDENT(LNO,0) :S(PAGEHDR)
33 IDENT(REMDR(LNO,NLP),0) :F(OUTIT)
34 PAGEHDR OUTREC = CHAR(12) CHAR(10) "Page " RPAD((PGNO = PGNO + 1),6)
34 + DATE() " " FIN DUPL(CHAR(10),2)
35 OUTIT OUTREC = ?(LNO = LNO + 1) (IDENT(SLNO) LPAD(LNO,6) ". ", NULL)
35 + LINE :(LOOP)
*
* Error handling statements
*
36 NOPT SCREEN = "Options must follow the semicolon on the command line." :(END)
37 END